<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>维护工作报告</title>
		<!-- css代码 start -->
		<link href="../../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../../css/global.css" rel="stylesheet" />
		<link href="../../../../css/style.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../../../css/mui.picker.css">
		<link rel="stylesheet" href="../../../../css/mui.poppicker.css">
		<link href="../../../../css/task.css" rel="stylesheet" />
		<style>
			.d_int_tp{
				border: 0 !important;
				margin-top: 6px !important;
			}
			input.d_ipt{
				padding: 0;
				color: #a9a9a9;
			}
			.mui-btn-block{
			    font-size: 16px;
			    color: #a9a9a9;
			    border: 0;
		   }
		   .details_con .btm .selectBtn {
		       line-height: 28px;
		       color: #ffffff;
		       background: #ea1e1a;
		   }
		   .select-tzstate{
				width: 100%;
				border: 0;
				color: #a9a9a9;
				font-size: 16px;
				text-align: left;
				padding: 15px;
		   }
		   .mui-bar-nav{
		   	box-shadow: 0 1px 6px #ea1e1a;
		   }
			.item_box .item .text{
				height: auto;
				min-height: 30px;
			}
		</style>
		<!-- css代码 end -->
	</head>

	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">维护工作报告</h1>
		</header>
		<div class="mui-content">
			<div class="details_con select_con">
				<div class="clum">
					<input type="text" id="customerName" class="d_int_tp" placeholder="请输入客户名称" />
				</div>
				<div class="clum">
					<span class="txt" style="width: 100%;">
						<button id='serviceType' class="mui-btn mui-btn-block mui-btn-select select-tzstate" type='button'>请选择服务子类型</button>
					</span>
				</div>
				<div class="clum">
					<input type="text" id="instSn" class="d_int_tp" placeholder="请输入仪器序列号" />
				</div>
				<div class="btm autoHeight">
					<p class="selectBtn" id="selectBtn">查 询</p>
				</div>
			</div>
			<div class="details_con" style="margin: 30px 0 0 0;">
				<div class="item_box" id="itemBox">
				</div>
				<div style="height: 50px;"></div>
			</div>
		</div>
		<!-- html代码 end -->

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/utils/h.js"></script>
		<script src="../../../../js/constant.js"></script>
		<script src="../../../../js/common.js"></script>
		<script src="../../../../js/utils/base64.js"></script>
		<script src="../../../../js/utils/md5.js"></script>
		<script src="../../../../js/utils/sortMap.js"></script>
		<script src="../../../../js/utils/http.js"></script>
		<script src="../../../../js/app.js"></script>
		<!-- 基础js end -->
		<script src="../../../../js/mui.picker.js"></script>
		<script src="../../../../js/mui.poppicker.js"></script>
		<script type="text/javascript" charset="utf-8">
			function initData() {
				h('#itemBox').html("");
				var customerName = h('#customerName').val() || '';
				var instSn = h('#instSn').val() || '';
				var serviceType = h('#serviceType').html();
				if (!serviceType || serviceType == '请选择服务子类型') {
					serviceType = '';
				}
				app.showWaiting()
				ajaxGet(BASE_URL + "cc/notice/getFseReportNotice", {
					"enginnerId": app.getUser().enginnerId,
					customerName,
					instSn,
					serviceType
				}, function(data) {
					app.closeWaiting()
					if (data.code === 200) {
						if (data.data && data.data.length > 0) {
							var str = '';
							for (var c = 0; c < data.data.length; c++) {
								str += '<div class="item" onclick="findReport(' + data.data[c].serviceNo + ')">';
								str += '<div class="bar">';
								var userTypeName = "";
								var enginnerType = data.data[c].enginnerType ? data.data[c].enginnerType : "";
								var isVip = data.data[c].isVip ? data.data[c].isVip : "";
								var userIsdpel = data.data[c].userIsdpel ? data.data[c].userIsdpel : "";
								if (userIsdpel == '1') {
									userTypeName = 'DPEL/';
								} 
								if(isVip != ""){
									userTypeName += isVip;
								}else{
									if(enginnerType != ""){
										userTypeName += enginnerType;
									}
								}
								str += '<span class="number"><img src="../../../../images/icon_204.png" />' + data.data[c].serviceNo +
									'</span><span class="vip">' + userTypeName +
									'</span>';
								str += '</div>';
								var customerName = data.data[c].customerName ? data.data[c].customerName : "";
								str += '<div class="text">';
								str += customerName;
								str += '</div>';
								str += '<div class="type">';
								var hopeBusinessHours = data.data[c].hopeBusinessHours ? data.data[c].hopeBusinessHours : "";
								var createTime = data.data[c].createTime ? data.data[c].createTime : "";
								var serviceType = data.data[c].serviceType ? data.data[c].serviceType : "";
								str += '<p><img src="../../../../images/icon_202.png"/><span class="lpl">提交时间：</span><span>' + createTime + '</span></p>'
								str += '<p><img src="../../../../images/icon_203.png"/><span class="lpl">服务类型：</span><span>' + serviceType + '</span></p>'
								str += '<p><img src="../../../../images/icon_202.png"/><span class="lpl">期望服务时间：</span><span>' + hopeBusinessHours +
									'</span></p>';
								str += '</div>';
								str += '</div>';
							}
							h('#itemBox').html(str);
						} else {
							noData()
						}

					} else {
						noData()
						app.toast(data.msg)
					}
				}, function(errorMsg) {
					app.closeWaiting()
					noData()
					app.toast("数据获取失败，请检查网络连接");
				});
			}

			function noData() {
				html = '<div class="nodata">—— 暂无数据 ——</div>';
				h("#itemBox").html(html);
			}

			(function($, doc) {
				$.init();

				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					initData()
					
					h('#selectBtn').tap(function(){
						app.hideSoftKeybord()
						initData()
					})

					h('#serviceType').tap(function(){
						app.hideSoftKeybord()
						var userPicker = new $.PopPicker();
						ajaxGetJson(BASE_URL + 'cc/dict/selectCCDict', {
							tableName: 'snsubtype',
							engineerId: app.getUser().enginnerId
						}, function (data) {
							if (!data) {
								app.toast("无下拉内容")
								return
							}
							// 数组指定位置插入数据
							// data.splice(0, 0, {"text": "请选择服务子类型", "value": ""});
							userPicker.setData(data);
							userPicker.show(function (items) {
								h('#serviceType').html(items[0].text)
								h('#serviceTypeValue').val(items[0].value)
								userPicker.dispose()
							});
						});
					})
				});
			}(mui, document));

			function findReport(serviceNo) {
				app.jumpTo("workReportList.html", "view/service/report/work/workReportList.html", {
					serviceNo: serviceNo
				});
			}
			// 跳转详情
			function jumpToDetail(serviceNo) {
				app.jumpTo("/view/workArea/service/serveDetails.html", "view/workArea/service/serveDetails.html", {
					"serviceNo": serviceNo,
					"enginnerId": app.getUser().enginnerId
				})
			}
		</script>
		<!-- js代码 end -->
	</body>

</html>
